import mongoose from '../dbHelper';
import { defaultSchemaExtend, defaultSchemaOptions } from "../config/index";

const Schema = mongoose.Schema;

const AiUserSchema = new Schema(Object.assign({
  userName: String,
  phone: {
    type: String,
    unique: true,
    required: true,
    length: 11
  },
  password: {
    type: String,
    // required: true,
    // maxlength: 16
  },
  // 剩余积分
  remainScore: {
    type: Number,
    default: 0
  },
  // 送的剩余积分
  remainSendScore: {
    type: Number,
    default: 0
  },
  // 剩余次数
  remainCount: {
    type: Number,
    default: 0
  },
  // 送的剩余次数
  remainSendCount: {
    type: Number,
    default: 0
  },

  usePhone: {
    type: String,
    default: ''
  },
  smsNum: { // 剩余短信额度
    type: Number,
    default: 0
  },
  login: {
    type: Boolean,
    default: false
  },
  success: {
    type: Boolean,
    default: false
  },
  fail: {
    type: Boolean,
    default: false
  },
  buy_auto_coups: {
    type: Boolean,
    default: false
  },
  auto_start_time: {
    type: Date,
    default: null
  },
  auto_end_time: {
    type: Date,
    default: null
  }

}, defaultSchemaExtend), defaultSchemaOptions);

const AiUser = mongoose.model('AiUser', AiUserSchema, 'AiUsers');

export default AiUser